Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WOL] Implement wake on LAN command line tool #19206

Merged
merged 40 commits into from
Aug 16, 2024
Merged

Conversation

w1nda
Copy link
Member

@w1nda w1nda commented Jun 5, 2024

Why I did it

Implement wake on LAN command line tool to send magic packets to target interface with extra parameters like mac address, password, count and interval.

Work item tracking
  • Microsoft ADO (number only): 28600376

How I did it

Setup rust compile environment, write code and test to implement the tool.
Set raw socket capacity for wol binary when build image.

How to verify it

Unit test and manually test with packet capture.

wendachu@wenda-dev-vm:~/sonic-buildimage/src/sonic-nettools$ cargo test
Finished test profile [unoptimized + debuginfo] target(s) in 0.02s
Running unittests src/main.rs (target/debug/deps/wol-a43f4ac2d14649cf)

running 9 tests
test wol::tests::test_build_magic_packet_without_password ... ok
test wol::tests::test_build_magic_packet ... ok
test wol::tests::test_is_ipv4_address_valid ... ok
test wol::tests::test_is_mac_string_valid ... ok
test wol::tests::test_parse_password ... ok
test wol::tests::test_parse_mac_addr ... ok
test wol::tests::test_parse_ipv4_addr ... ok
test wol::tests::test_parse_target_macs ... ok
test wol::tests::verify_args_parse ... ok

test result: ok. 9 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211
  • 202305

Tested branch (Please provide the tested image version)

Description for the changelog

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@w1nda w1nda requested review from liushilongbuaa and xumia June 5, 2024 08:25
}

#[test]
fn verify_args_parse() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to split this testcase to several testcases, each one for a single argument or scenario.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test is quite lite weight and easy to run, so I prefer to put them together, if they are together, it easy to review and easy to find out if anything miss.

Run test demo:
image

@lizhijianrd
Copy link
Contributor

Can you help answer below questions in PR description:

  1. Build/Compile environment is cleaned up, which means SONiC image doesn't contain the build env.
  2. Paste unittest result to How to verify it section.
  3. It the manually functionality test passed on both x86 and armhf?

@w1nda w1nda requested a review from liushilongbuaa August 8, 2024 03:24
@w1nda
Copy link
Member Author

w1nda commented Aug 8, 2024

Can you help answer below questions in PR description:

  1. Build/Compile environment is cleaned up, which means SONiC image doesn't contain the build env.
  2. Paste unittest result to How to verify it section.
  3. It the manually functionality test passed on both x86 and armhf?
  1. Yes, the SONiC image doesn't contain the build env.
  2. Updated.
  3. Yes, the unit tests were ran in buildimage pipeline, and it passed on all hardware sku.

@w1nda
Copy link
Member Author

w1nda commented Aug 8, 2024

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@w1nda
Copy link
Member Author

w1nda commented Aug 15, 2024

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@liushilongbuaa
Copy link
Contributor

/azpw ms_conflict -f

@@ -362,6 +362,15 @@ CROSS_COMPILE_FLAGS := CGO_ENABLED=1 GOOS=linux GOARCH=$(GOARCH) CROSS_COMPILE=$

endif

ifeq ($(CROSS_BUILD_ENVIRON),y)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if you understand CROSS_BUILD_ENVIRON correctly.
Do you try to build arm SONiC image on amd64 machine?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I'm trying install toolchain if user want to do cross build.

@w1nda
Copy link
Member Author

w1nda commented Aug 16, 2024

Hi @yxieca, cloud you help merge this PR?

@yxieca yxieca merged commit 92f9378 into sonic-net:master Aug 16, 2024
23 checks passed
matiAlfaro pushed a commit to Marvell-switching/sonic-buildimage that referenced this pull request Aug 21, 2024
Why I did it
Implement wake on LAN command line tool to send magic packets to target interface with extra parameters like mac address, password, count and interval.

How I did it
Setup rust compile environment, write code and test to implement the tool.
Set raw socket capacity for wol binary when build image.

How to verify it
Unit test and manually test with packet capture.
mssonicbld pushed a commit to mssonicbld/sonic-buildimage that referenced this pull request Dec 11, 2024
Why I did it
Implement wake on LAN command line tool to send magic packets to target interface with extra parameters like mac address, password, count and interval.

How I did it
Setup rust compile environment, write code and test to implement the tool.
Set raw socket capacity for wol binary when build image.

How to verify it
Unit test and manually test with packet capture.
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202405: #21136

bingwang-ms pushed a commit that referenced this pull request Dec 12, 2024
Why I did it
Implement wake on LAN command line tool to send magic packets to target interface with extra parameters like mac address, password, count and interval.

How I did it
Setup rust compile environment, write code and test to implement the tool.
Set raw socket capacity for wol binary when build image.

How to verify it
Unit test and manually test with packet capture.

Co-authored-by: Wenda Chu <[email protected]>
@w1nda
Copy link
Member Author

w1nda commented Dec 12, 2024

Cherry-pick to 202405 successfully, however, the labels are not updated,
I will update it manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants